Skip to content

Conversation

@humandetail
Copy link

When the switch does not meet some business conditions and is rejected (the value does not change), the input radio is actually marked as checked internally, and clicking the switch again cannot trigger the change event.

Here is an example:

<template>
  <a-segmented :value="value" :options="data" @change="handleChange" />
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { Modal } from 'ant-design-vue';
const data = reactive(['Daily', 'Weekly', 'Monthly', 'Quarterly', 'Yearly']);
const value = ref(data[0]);
const confirm = () => {
  return new Promise(resolve => {
    Modal.confirm({
      title: 'Confirm',
      content: 'Are you sure you want to confirm?',
      onOk: () => {
        resolve(true);
      },
      onCancel: () => {
        resolve(false);
      },
    });
  });
};
const handleChange = v => {
  confirm().then(res => {
    if (res) {
      value.value = v;
    } else {
      console.log('reject');
    }
  });
};
</script>

@github-actions
Copy link

github-actions bot commented May 7, 2025

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label May 7, 2025
@github-actions github-actions bot closed this May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant